#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    for (int T = read(); T--;) {
        string s = read<string>();
        transform(s.begin(), s.end(), s.begin(), [](char ch) { return islower(ch) ? toupper(ch) : tolower(ch); });
        cout << s << endl;
    }

    return 0;
}
